<form role="form" data-toggle="validator" class="form-horizontal">
    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
        <!-- 基本信息板块 -->
        <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                    <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                        <i class="fa fa-info-circle"></i> 基本信息
                    </a>
                </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                <div class="panel-body">
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品状态')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">
                                {if condition="$row.audit_status eq 0"}
                                    <span class="label label-danger">审核未通过</span>
                                {elseif condition="$row.audit_status eq 1"/}
                                    <span class="label label-success">审核通过</span>
                                {elseif condition="$row.audit_status eq 2"/}
                                    <span class="label label-warning">待审核</span>
                                {/if}
                                &nbsp;
                                {if condition="$row.shelf_status eq 0"}
                                    <span class="label label-warning">下架</span>
                                {elseif condition="$row.shelf_status eq 1"/}
                                    <span class="label label-success">上架</span>
                                {/if}
                            </p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('所属商家')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.merchant_name|htmlentities}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品名称')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.name|htmlentities}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品ID')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.id}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品类型')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.category_name|htmlentities}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品销量')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.sales|default='0'}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('创建时间')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.createtime}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('更新时间')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.updatetime}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 商品图片信息板块 -->
        <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                        <i class="fa fa-image"></i> 商品图片信息
                    </a>
                </h4>
            </div>
            <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
                <div class="panel-body">
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品主图')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <div class="row">
                                {foreach name="mainImages" item="image"}
                                <div class="col-xs-6 col-md-3">
                                    <a href="{$image.image_url}" target="_blank" class="thumbnail">
                                        <img src="{$image.image_url}" alt="商品主图" style="max-height: 150px;">
                                    </a>
                                </div>
                                {/foreach}
                                {if condition="empty($mainImages)"}
                                <div class="col-xs-12">
                                    <p class="form-control-static">暂无商品主图</p>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品详情图')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <div class="row">
                                {foreach name="detailImages" item="image"}
                                <div class="col-xs-6 col-md-3">
                                    <a href="{$image.image_url}" target="_blank" class="thumbnail">
                                        <img src="{$image.image_url}" alt="商品详情图" style="max-height: 150px;">
                                    </a>
                                </div>
                                {/foreach}
                                {if condition="empty($detailImages)"}
                                <div class="col-xs-12">
                                    <p class="form-control-static">暂无商品详情图</p>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 规格与销售板块 -->
        <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingThree">
                <h4 class="panel-title">
                    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
                        <i class="fa fa-list"></i> 规格与销售
                    </a>
                </h4>
            </div>
            <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
                <div class="panel-body">
                    {if condition="!empty($skus)"}
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>规格名称</th>
                                    <th>SKU编码</th>
                                    <th>供货价格</th>
                                    <th>权益商品价格</th>
                                    <th>积分商品价格</th>
                                    <th>库存</th>
                                    <th>总销量</th>
                                    <th>规格图片</th>
                                </tr>
                            </thead>
                            <tbody>
                                {foreach name="skus" item="sku"}
                                <tr>
                                    <td>{$sku.sku_name|htmlentities}</td>
                                    <td>{$sku.sku_code|htmlentities}</td>
                                    <td>￥{$sku.price}</td>
                                    <td>￥{$sku.market_price|default='0.00'}</td>
                                    <td>￥{$sku.original_price|default='0.00'}</td>
                                    <td>{$sku.stock}</td>
                                    <td>{$sku.sales|default='0'}</td>
                                    <td>{if condition="!empty($sku.image)"}<img src="{$sku.image}" style="max-height:50px;max-width:50px;">{else/}无图片{/if}</td>
                                </tr>
                                {/foreach}
                            </tbody>
                        </table>
                    </div>
                    {else/}
                    <div class="form-group">
                        <div class="col-xs-12">
                            <p class="form-control-static">该商品没有规格信息</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品价格')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">￥{$row.price}</p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-2">{:__('商品库存')}:</label>
                        <div class="col-xs-12 col-sm-8">
                            <p class="form-control-static">{$row.stock}</p>
                        </div>
                    </div>
                    {/if}
                </div>
            </div>
        </div>
    </div>
    
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="button" class="btn btn-primary" onclick="closeLayer()">{:__('Close')}</button>
        </div>
    </div>
    
<script>
function closeLayer() {
    // 尝试多种方式关闭弹窗
    try {
        if (typeof parent.layer !== 'undefined') {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        } else if (typeof layer !== 'undefined') {
            layer.closeAll();
        } else if (window.parent && window.parent !== window) {
            window.parent.postMessage('closeLayer', '*');
        }
    } catch (e) {
        console.log('关闭弹窗失败:', e);
        // 最后尝试关闭窗口
        if (window.parent && window.parent !== window) {
            window.parent.location.reload();
        }
    }
}
</script>
</form>